//
//  EMSettingViewController.m
//  ElectronicMall
//
//  Created by 史伟文 on 15/1/7.
//  Copyright (c) 2015年 cczu. All rights reserved.
//

#import "EMSettingViewController.h"
#import "UINavigationController+EMNavi.h"
@interface EMSettingViewController ()
{
    UIButton *massageSwitch;
    BOOL switchOn;
}
@end

@implementation EMSettingViewController

- (void)hideBottomBar
{
    for(UIView *view in self.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
            view.hidden = YES;
    }
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self hideBottomBar];
    self.view.backgroundColor = RGB(242, 242, 242);
    [self.navigationController setNavigationMode:EMNavigationModeDefault andSubMode:0];
    self.navigationItem.title = @"系统设置";
    
    UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame=CGRectMake(0, 0, 30, 32);
    [button setImage:[UIImage imageNamed:@"button_导航_返回_白"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithCustomView:button];
}
- (void)backAction: (UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    int height = 64 + 15;
    UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, height, 280, 20)];
    versionLabel.text = @"消息";
    versionLabel.textColor = [UIColor lightGrayColor];
    versionLabel.textAlignment = NSTextAlignmentLeft;
    versionLabel.font = [UIFont fontWithName:HEITIMEDIUM size:16];
    [self.view addSubview:versionLabel];
    
    height += 20 + 5;
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10, height, W(300), 0.5)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:lineView];
    
    height += 10;
    UILabel *wcTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, height, 280, 20)];
    wcTitleLabel.text = @"接收消息通知";
    wcTitleLabel.textColor = [UIColor darkGrayColor];
    wcTitleLabel.textAlignment = NSTextAlignmentLeft;
    wcTitleLabel.font = [UIFont fontWithName:HEITIMEDIUM size:14];
    [self.view addSubview:wcTitleLabel];
    
    massageSwitch = [UIButton buttonWithType:UIButtonTypeCustom];
    massageSwitch.frame = CGRectMake(W(240), height-5, 60, 30);
    [massageSwitch setImage:[UIImage imageNamed:@"icon_开关_关"] forState:UIControlStateNormal];
    [massageSwitch addTarget:self action:@selector(switchPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:massageSwitch];
}

- (void)switchPressed:(UIButton *)sender
{
    if (switchOn) {
        [massageSwitch setImage:[UIImage imageNamed:@"icon_开关_关"] forState:UIControlStateNormal];
    } else {
        [massageSwitch setImage:[UIImage imageNamed:@"icon_开关_开"] forState:UIControlStateNormal];
    }
    switchOn = !switchOn;
}

@end
